;; Sri Ganeshji : Sri Balaji : Sri Pitreshwarji : Sri Durgaji : Sri Venkateshwara

;;Sync as Consolidated JV

[Variable:VouOptDate]

	Type		:	Date
 	Default		:	$$Date:##SVCurrentDate 	;;$LastVoucherDate:Company:##SVCurrentCompany ;;##SVCurrentDate 

[System:Variable]

	VouOptDate	:	$$Date:##SVCurrentDate	;;$LastVoucherDate:Company:##SVCurrentCompany
	
[#Menu	:	Gateway of Tally]

	Item	:	Group Vouchers	:	Create :	Change Vou Date

[Report	:	GrpVou]

	Object		:	Voucher
	Form		:	GrpVou
	Set			:	OptionalFlag	:	Yes		
	Set			:	SVVoucherType	:	"Journal"
	Set			:	SVFromDate		:	$$Date:##SVCurrentDate 
	Variable	:	VouOptDate
	Title		:	"Creation of Journal Voucher"
	
[Form	:	GrpVou]

	Width		:	100% Screen
	Height		:	100% Screen
	Part		:	VouPart
	Button		:	Change Opt Date
	Background	:	Light Yellow

;;********Parts

[Part	:	VouPart]

	Line		:	VouLine
	Repeat		:	VouLine	:	PVouchers ;;LedVouchers ;;
	Set			:	1
	Scroll		:	Vertical

[Part	:	DetPart]

	Line		:	DetLine  ;;,TotLine
	Bottom Line	:	NarrLine
	Repeat		:	DetLine	:LedgerEntries
	Set			:	$$NumItems:MyLedgers	;;;2 ;;+ $$NumItems:MyLedgers1
	Scroll		:	Vertical
	Totals		:	VDrAmt,VCrAmt

[Part	:	CCAllocPart]

	Line	:	CCLine
	Repeat	:	CCLine	:Costcentre Allocations
	Scroll	:	Vertical
	Set		:	$$NumItems:CC

;;*************Lines

[Line	:	VouLine]

	Left Fields	: VouNameF,VouNoT,VouNoF,Medium Prompt,VouOptional
	Right Fields: Simple Prompt,VouDateF,VouDateEffective
	Explode		: DetPart
	Border		: Thin Bottom
	Local	:	Field	:	Simple Prompt	:	Info	:	"Date	:"
	Local	:	Field	:	Medium Prompt	:	Info	:	"Optional"
	Local	:	Field	:	Medium Prompt	:	FullWidth:	Yes
	Local	:	Field	:	Medium Prompt	:	Align	 :  Centre

[Line	:	DetLine]
	Fields			:	ByToF,DPosfld,LedFld
	Right Fields	:	VDrAmt,VCrAmt,VAmount
	Explode			:   CCatAllocPart: @@CCOn 

[Part:CCatAllocPart]	
	Line			:   CCatAlloc
	Repeat			:   CCatAlloc:CategoryAllocations
	Scroll			:   Vertical
	Set 			:   1

[Line :CCatAlloc]
	Field			: CCatFld,LedFld
	Explode			: CCAllocPart : Yes 	;;And $$IsEven:$$Line 	;;@@IsCCApplLed And $$IsEven:$$Line
	Local			: Field :LedFld:Set As :$$ExplodeOwner:#LedFld
	Local			: Field :LedFld:Invisible :Yes

[Field : CCatFld]
	Use			: Name Field
	Set As 		: "Doctors"
	Storage 	: Category
	Set Always  : Yes
		
[Line	:	TotLine]
	Right Fields	:	TotDr ,TotCr
	Border			:	Double top	
 
[Line:NarrLine]
	Field			:	Medium Prompt,NarrFld
	Local			:   Field	:Medium Prompt	:	Info	:	"Narration  :"	

[Line:CCLIne]
	Field			:	LedFld,CCNameFld,CCAmtFld
	Indent			:	8
	Local			: Field :LedFld:Set As:$$ExplodeOwner:#LedFld
	Local			: Field :LedFld:Invisible :Yes

[Field	:	CCNameFld]
	Use				:	Name Field
	Set as			:	@@CCNameVal
	Storage			:	Name
	Skip			:	Yes
	Style			:	Normal Italic

[Field	:	CCAmtFld]
	Use				:	Amount Field
	Type			:	Amount		:	Forced
	Set always		:   Yes
	Set as			:	$$Abs:@@CCDrLedTotLed  ;;:Ledger:#LedFld  ;;CCLedBal
	Storage			:	Amount
	Format      	: 	"All Symbols,DrCr"
	Skip			:	Yes
	Style			:	Normal Italic

;;**********Fields
[Field	:	NarrFld]
	Use         	:	Voucher Narration Field
    Lines       	:	4
    Storage     	:	Narration
    Width       	:	50% Screen
	Background		:	Light Yellow

[Field	:	TotDr]
	Use				:	Amount Base Field
	Type			: 	Amount 	: Direct Base
    Width       	: 	@@VCHAmountWidth
	Set as			:	$$Total:VDrAmt  ;;@@TotDrAmtLed
	Skip			:	Yes
	  
[Field	:	TotCr]
	Use				:	Amount Base Field
	Type			: 	Amount 	: Direct Base
    Width       	: 	@@VCHAmountWidth
	Set as			:	$$Total:VCrAmt  ;;@@TotCrAmtLed
	Skip			:	Yes
		
[Field	:	ByToF]
	Use				:	Name Field
	Set as			:	if $$IsDr:$FinBal2:Ledger:@LocalFld then "Dr" else "Cr" 
	LocalFld		:	$$CollectionField:$Name:$$Line:MyLedgers
	Skip			:	Yes

[Field	:	DPosfld]
	Use				:	Logical Field
	Type			:	logical	:	Forced
	Set Always		:	Yes
;;	Set as			:	(#ByToF STARTING WITH "B") OR (#ByToF STARTING WITH "D")
	Set as			:	if @@DPos=No then Yes else No  ;;(#ByToF STARTING WITH "B") OR (#ByToF STARTING WITH "D")
	Storage			:	Is Deemed Positive
	Invisible		:	Yes
	Skip			:	Yes
	
[Field	:	LedFld]
	Use				:	Name Field
	Set as			:	$$CollectionField:$Name:$$Line:MyLedgers	;;if (@@CCOn And $$IsEven:$$Line) or ($$IsOdd:$$Line) then @@LName else ""
	Storage			:	LedgerName
	Skip			:	Yes

[Field	:	DTFld]
	Use				:	VCH DirectTaxBills
	Skip			:	Yes
	
[Field	:	ACCVatFld]
	Use				:	VCH ACCVATClass
	Skip			:	Yes
	
[Field	:	VATAssesValue]
	Use				:	EI VATAssessableValue
	Skip			:	Yes
	
[Field	:	VDrAmt]
    Use         	: 	Amount Base Field
	Type			: 	Amount : Direct Base
    Width       	: 	@@VCHAmountWidth
	Inactive		:	@@DPos	
;;	set as			:	@@FinBal   ;;$$Abs:@@FinBal 
	Set as			:	$FinBal2:Ledger:@LocalFld 	;;If $$IsOdd:$$Line then $AddlLedAmt:Ledger:#LedFld +
;;						else $CCTotAmt:Ledger:#LedFld ;;CCDrLedTotLed1
	Skip			:	Yes
	LocalFld		:	$$CollectionField:$Name:$$Line:MyLedgers

[Field	:	VCrAmt]
    Use         	: 	Amount Base Field
	Type			: 	Amount 	: Direct Base
    Width       	: 	@@VCHAmountWidth
	Inactive		:	Not @@DPos	
;;	Set as			:	$$Abs:@@FinBal
	Set as			:	$FinBal2:Ledger:@LocalFld	;;If $$IsOdd:$$Line then $$Abs:$AddlLedAmt:Ledger:#LedFld +
;;						else $$Abs:$CCTotAmt:Ledger:#LedFld  ;;CCDrLedTotLed
	Skip			:	Yes
	LocalFld		:	$$CollectionField:$Name:$$Line:MyLedgers
		
[Field	:	VAmount]
	Type			:	Amount	:	Forced
	Set Always		:	yes
	Use				:	Amount Field
	Set as			:	If #DPosfld then #VDrAmt-#VCrAmt else #VCrAmt-#VDrAmt
	Storage			:	Amount
	Format      	: 	"All Symbols,DrCr"
	Skip			:	Yes
;;	Invisible		:	Yes

;;Fields

[Field	:	VouDateF]
	Use				:	Uni Date Field
	Set as			:	$$Date:##VouOptDate
	Skip			:	Yes
	Storage			:	Date

[Field	:	VouDateEffective]
	Use				:	Uni Date Field
	Set as			:	$$Date:##VouOptDate
	Skip			:	Yes
	Storage			:	EffectiveDate
	
[Field	:	VouNameF]
	Use				:	Name Field
	Set as			:	"Journal Sync"
	Storage			:	VoucherTypeName
	Skip			:	Yes
	Align			:	Centre	
;;	Background		:	Red

[Field	:	VouNoT]
	Use				:	Name Field
	Width			:	10
	Set as			:	" No.	:"
	Skip			:	Yes

[Field	:	VouNoF]
	Use				:	Name Field
	Set as			:	"Opt" + $$String:##VouOptDate
	Skip			:	Yes
	Storage			:	VoucherNumber
	
[Field: VouOptional]
    Use         	:	Logical Field
    Storage     	:	Is Optional
    Set as      	:	Yes
    Set always  	:	Yes
    Invisible   	:	Yes
    Skip        	:	Yes

;;***********
[System	:	Formula]
 	CCOn				:	$IsCostcentresOn:Ledger:@@LName  
	DPos				:	If $$IsDr:$FinBal2:Ledger:#LedFld  then  No else Yes
	LName				:	$$CollectionField:$Name:$$Line:MyLedgers
 	NoBalFlt			:	(Not $$IsEmpty:$FinBal2) And $Name !="Profit & Loss A/C" 	 
	NoBalCC				: 	(Not $$IsEmpty:$CCDrTotalAmt) OR (Not $$IsEmpty:$CCCrTotalAmt)
	DateFilter			:	$Date=$$Date:##VouOptDate

	;;***************Cost Centres
	CCNameVal			:	$$CollectionField:$Name:$$Line:CC

	CCDrLedTot			:	$$AllocCCLedDrTotal:@@CCNameVal:#LedFld
	CCCrLedTot			:	$$AllocCCLedCrTotal:@@CCNameVal:#LedFld

	Grp					:	""

	CCDrLedTotLed		:	$$FilterAmttotal:LedVouchers:DateFilter:$CCLedBal    
	 
[#Object : CostCentre]
	CCDrTotalAmt : $$FromValue:##VouOptDate:$$ToValue:##VouOptDate:$$CCGLDebits:#LedFld:"":#CCIsDirectCost 
	CCCrTotalAmt : $$FromValue:##VouOptDate:$$ToValue:##VouOptDate:$$CCGLCredits:#LedFld:"":Yes   
	 
[#Object : Ledger]
  	FinBal2		:  $FinBalCl -	$FinBalOp		 
	FinBalOp	:  $$FromValue:##SVCurrentDate:$$ToValue:##SVCurrentDate:$OpeningBalance	 
	FinBalCl	:  $$FromValue:##SVCurrentDate:$$ToValue:##SVCurrentDate:$ClosingBalance	 

[#Object : Voucher]
	CCLedBal	:	@@CCDrLedTot - @@CCCrLedTot
 
[Collection	:	CC]
	Type	:	Cost centre
	Filter 	:   NoBalCC

;;**************
[Collection		:	MyStockItem]
	Type		:   Stock Item
	
;;*************************

[Collection	:	PVouchers]

	Type	:	Voucher

[Collection	:	MyLedgers]
	Type		:	Ledger
	Filter		:	NoBalFlt
;	Filter 		:   NonPartyLedger
    Sort    	: 	Default		: $FinBal2

[Collection: LedVouchers]
    Type        :	Vouchers  :	Ledger
    Child of    :	#LedFld
	Filter		:	DateFilter

;;************    	
[Button	:	Change Opt Date]
    Key     	:	F3
    Title   	:	$$LocaleString:"Vou. Date"
    Action  	:	Execute : Change Vou Date

;;**********    
[Report	:	Change Vou Date]
	Form	:	Change Vou Date
	
[Form	:	Change Vou Date]
	Part	:	Change Vou Date
	
[Part	:	Change Vou Date]
	Line	:	Change Vou Date
	
[Line	:	Change Vou Date]
	Fields	:	Medium Prompt , ChgVouDate
	Local	:	Field	:	Medium Prompt	:	Info	:	"Date "
	Local	:	Field	:	Medium Prompt	:	Skip	:	Yes
	
[Field	:	ChgVouDate]
	Use			:	Uni Date Field
;;	Set As		:   $$Date:##SVCurrentDate  
	Modifies	:	VouOptDate
	Variable	:   VouOptDate
 	Subform		:	GrpVou
;;******************




[System				:	Formula]
	vchtypToBeSync	: 	$vchtypToBeSynchronized:VoucherType:$VoucherTypeName=Yes
[System		:	UDF]
	vchtypToBeSynchronized		:	Logical	:	7

[#Part: VTYP Behaviour]
	Add: Line:At End:VTYP TOBESYNC

	[Line:	VTYP TOBESYNC]
		Field: Medium Prompt,fToBeSynchronized
		Local:	Field:	Medium Prompt:Setas:"To be Synchronized"

		[Field:	fToBeSynchronized]
			Use		:	Logical Field
			Storage	:	vchtypToBeSynchronized

;[#Collection	:	SVSendRemoteMsgs]
;		Filter	:	vchtypToBeSync

[#Collection: SVSendClientMsgs]

	Filter	:	vchtypToBeSync

[Collection		:	colVoucherType]
	Type		:	Voucher Type
	Belongs To  	: Yes